package asimes.neteasy;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created by Liangweiwei on 2016/9/12.
 */
public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<>();
        String line = scanner.nextLine();
        while (line.length()!=0){
            list.add(Integer.parseInt(line));
            line=scanner.nextLine();
        }
        for (int i = 0; i < list.size(); i++) {
            int n = list.get(i);
            if (n == 2)
                System.out.println(9);
            else
                System.out.println((int) Math.pow(3, n) - getDarkCount(n));

        }
//        int n = scanner.nextInt();
//        if (n == 2)
//            System.out.println(9);
//        else
//            System.out.println((int) Math.pow(3, n) - getDarkCount(n));
    }

    public static int getDarkCount(int n) {
        int count = 0;
        if (n == 3) {
            count += 6;
        } else {
            int tmp = getDarkCount(n - 1);
            count = getDarkCount(n - 1) * 3 * 2 - getDarkCount(n - 1);
        }

        return count;
    }
}
